
global user "dveracossio"
global dirdata "C:\Users\\$user\Dropbox\CCT BJP\data"
global dir1  "$dirdata\Final data"
global dir2  "$dirdata\Results\graphs"
global dir3  "$dirdata\Results\"
cd "$dir3"

use "$dir1\pooled_hh.dta", clear
keep if tau>-5  
g age=age_m if hhmale==0
replace age=age_p if hhmale==1
g spanish=spanish_m if hhmale==0
replace spanish=spanish_p if hhmale==1

g Post=tau>=0
egen w_hoursw_head=rowtotal(w_hoursw_p w_hoursw_m)
g work_head=(w_hoursw_head>0)
replace work_head=. if work_m==. & work_p==.

g work_both=work_m==1 & work_p==1
replace work_both=. if work_m==. & work_p==.


g work_one=(work_m==1 & work_p==0) | (work_m==0 & work_p==1)
replace work_one=. if work_m==. & work_p==.

g work_male_only= (work_m==0 & work_p==1)
replace work_male_only=. if work_m==. & work_p==.

g work_female_only= (work_m==1 & work_p==0)
replace work_female_only=. if work_m==. & work_p==.

local nwork_lab "# of working adults"
local w_hoursw_t_lab "Hours/week"
local work_head_lab "Worked last week"
local w_hoursw_head_lab "Hours/week"
local work_m_lab "Worked last week"
local work_p_lab "Worked last week"
local w_hoursw_m_lab "Hours/week "
local w_hoursw_p_lab "Hours/week "
local parm Post
local replace replace


global covs1 "age_m spanish_m schooling_m  age_p spanish_p schooling_p  hhmale urban np nchild5 age_sac  c.age_sac#i.year c.np#i.year  i.departamento#i.year i.year"
 
local spec1  Post i.min_schooling  $covs1  

local sample1 "(min_schooling>=1 & min_schooling<9)"

local top1 "All"

keep if work_m!=. & work_p!=.
**keeping only biparental hhs

local replace replace
foreach x in work_head work_one work_male_only work_female_only work_both {
foreach y in 1  {
sum `x'   if tau==-1 & `sample`y''
local mean_dv=r(mean)
areg `x'  `spec`y''  if `sample`y'',a(departamento) cluster(municipio)
outreg2 using "$dir3\Table7", excel `replace' ctitle(``x'_lab') keep(`parm') less(0) nocons  bdec(3) cttop(`top`y'') adds(Clusters, e(N_clust),Mean DV, `mean_dv') alpha(0.01, 0.05, 0.1) addtext(Avg. age X year FE,  YES, HH size X year FE, YES )   
local replace append
}
}
